# Contributor: David Huffman <storedbox@outlook.com>
# Maintainer: David Huffman <storedbox@outlook.com>

_gosu_repo='github.com/tianon/gosu'
_gosu_ver=1.12
_gosu_src="gosu-$_gosu_ver"

_runc_repo='github.com/opencontainers/runc'
_runc_ver=1.0.0-rc91
_runc_src="runc-$_runc_ver"

pkgname=gosu
pkgver=$_gosu_ver
pkgrel=0
pkgdesc="Simple Go-based setuid+setgid+setgroups+exec"
url="https://github.com/tianon/gosu"
arch="all !mips !mips64" # go is missing
license="GPL-3.0-or-later"
makedepends="coreutils go"
source="https://github.com/tianon/gosu/archive/$_gosu_ver/$_gosu_src.tar.gz
	https://github.com/opencontainers/runc/archive/v$_runc_ver/$_runc_src.tar.gz"
options="!check" # require docker to run tests

builddir="$srcdir"/$_gosu_repo
prepare() {
	mkdir -p $_gosu_repo $_runc_repo
	mv -T $_gosu_src $_gosu_repo
	mv -T $_runc_src $_runc_repo

	default_prepare
}

build() {
	CGO_ENABLED=0 GOPATH="$startdir:$srcdir/$_runc_repo/Godeps/_workspace" \
		go build -v -ldflags '-s -w'
}

package() {
	local bindir="$pkgdir/usr/bin"
	mkdir -p "$bindir"
	cp gosu "$bindir"
}

sha512sums="3f8874ab3cefee3332d3a89541c395f7de3b5f758c7464f7a1cb5614ceb15ed69119bdc9628eb56a9d9830fe0f93bc72f36bce9669a3c0cc3dae9db4d677a7e3  gosu-1.12.tar.gz
9e639c0de1b6bc414fc909c4342590e00d8473b06cfa6e38fa47eef0afb00e811f2b9a83913fb5ad0fa1691e88a9dd9d280367b4f8a9e4746a5c8b522d7ad74c  runc-1.0.0-rc91.tar.gz"
